﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace GodPl.GameObjects.Creatures.Actions
{
    public class AEatFrom : BriyyaAction
    {
        static readonly TimeSpan minDuration = new TimeSpan(0, 0, 2);
        static readonly TimeSpan maxDuration = new TimeSpan(0, 0, 2);

        public AEatFrom(Briyya actor, IFoodSource target) : base(actor, (GameObject)target)
        {
            assertTarget();
            assertDistance();
        }

        public override void Begin()
        {
            base.Begin();
            IFoodSource foodTarget = (IFoodSource)target;
            if (!foodTarget.IsStocked)
            {
                this.Finish();
            }

            foodTarget.BeEatenFrom(actor);

            actor.Drives[DriveName.Hunger] -= foodTarget.Nutritiousness;

            this.Finish();
        }

        protected override TimeSpan MinDuration
        {
            get { return minDuration; }
        }

        protected override TimeSpan MaxDuration
        {
            get { return maxDuration; }
        }
    }
}
